<template>
  <view class="category">
    <navigator class="item" v-for="item in category" :key="item.id" :url="`/pages/imgCategory/index?id=${item.id}`">
      <image :src="item.cover" mode="aspectFill"></image>
      <view class="name">{{item.name}}</view>
    </navigator>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        category:[]
      }
    },
    mounted() {
      uni.setNavigationBarTitle({title:"分类"})
      this.getList()
    },
    methods: {
      //http://157.122.54.189:9088/image/v1/vertical/category
      getList(){
        this.request({url:"http://157.122.54.189:9088/image/v1/vertical/category"})
        .then(res=>{
          this.category=res.res.category
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
.category{
  display: flex;
  flex-wrap: wrap;
  .item{
    width: 33.33%;
    position: relative;
    padding: 5rpx;
    image{
      width: 240rpx;
    }
    .name{
      position: absolute;
      width: 100%;
      height: 50rpx;
      left: 0;
      bottom: 0;
      color: #fff;
      background-image: linear-gradient(to right top,rgba(0,0,0,.2),rgba(0,0,0,0));
      font-size: 40rpx;
      display: flex;
      align-items: center;
      padding-left: 20rpx;
    }
  }
}
</style>